#include "zonewidget.h"

ZoneWidget::ZoneWidget(QWidget *parent) :
  QFrame(parent)
{
}

ZoneWidget::ZoneWidget(const Zone &z)
{
  setContentsMargins(4,4,4,4);
  setFrameShape(QFrame::StyledPanel);

  name.setText(z.name() + " (" + QString::number(z.level()) + ")");
  layout.addWidget(&name);
  if(z.eventName() != "")
    {
      eventName.setText(z.eventName());
      eventTimer.setText(tr("Started %1 ago").arg(z.eventTime().toString().toUtf8().data()));

      QPalette pal;
      pal.setColor(QPalette::Foreground, QColor(255, 0, 0));
      setAutoFillBackground(true);
      setPalette(pal);
    }
  else
    {
      eventName.setText(tr("No event"));
    }

  layout.addWidget(&eventName, 0, Qt::AlignRight);
  layout.addWidget(&eventTimer, 0, Qt::AlignRight);
  //layout.addLayout(&secondLine);

  setLayout(&layout);
}
